<template>
	<!-- home文章列表 -->
	<view class="item" @tap="goToArticleDetail()">
		<!-- 文章标题 -->
		<view class="title">
			{{title}}
		</view>
		<!-- 文章主体内容区域 左右布局-->
		<view class="content">
			<!-- 左侧文章信息 -->
			<view class="info">
				<!-- 文章摘要 -->
				<view class="abstract">
					{{description}}
				</view>
				<!-- data阅读量 -->
				<view class="tips">
					<text class="date">{{handleTime}}</text>
					<text class="views">{{views}} 阅读</text>
				</view>
			</view>
			<!-- 右侧文章封面 -->
			<view class="cover">
				<image class="img" :src="coverImageUrl"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			};
		},
		props: {
			title: {
				type: String
			},
			description: {
				type: String
			},
			coverImageUrl: {
				type: String
			},
			views: {
				type: String
			},
			createTime: {
				type: String
			},
			articleId: {
				type: String
			}
		},
		methods: {
			goToArticleDetail() {
				uni.navigateTo({
					// url: 'test?id=1&name=uniapp'  c传递参数
					url: "/pages/home/articleDetail?articleId=" + this.articleId
				})
			}
		},
		computed: {
			handleTime() {
				// 分割取T前面
				let time = this.createTime.split('T')
				return time[0]
			}
		}
	}
</script>

<style lang="scss">
	.item {
		padding: 30rpx;
		margin-top: 30rpx;
		background-color: #FFF;

		// 文章标题
		.title {
			padding-bottom: 30rpx;
			border-bottom: 2rpx solid #F5F5F5;
			@include conent-title(32rpx, 700)
		}

		// 文章内容左右布局
		.content {
			display: flex;
			justify-content: space-between;
			margin-top: 30rpx;

			// 左侧信息
			.info {
				width: calc(100% - 160rpx);

				// 文章描述
				.abstract {
					height: 110rpx;
					color: $bsin-abstract;
					line-height: 38rpx;
					@include text-ellipsis(3);
				}

				.tips {
					display: flex;
					justify-content: space-between;
					margin-top: 14rpx;

					.date {
						color: $bsin-color-data;
					}

					.views {
						color: $bsin-abstract;
					}
				}
			}

			// 右侧封面
			.cover {
				width: 140rpx;
				height: 140rpx;

				.img {
					width: 100%;
					height: 100%;
					border-radius: 10rpx;
				}
			}
		}
	}
</style>
